package cn.stylefeng.guns.modular.business.controller;


import cn.stylefeng.guns.modular.business.pojo.FigureInfoRequest;
import cn.stylefeng.guns.modular.business.service.FigureInfoService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 人物基本信息控制器
 *
 * @author zhangyaowen
 * @date 2021/10/25 16:46
 */
@RestController
@ApiResource(name = "人物基本信息")
public class FigureInfoController {

    @Resource
    private FigureInfoService figureInfoService;

    /**
     * 添加
     *
     * @author zhangyaowen
     * @date 2021/10/25 16:46
     */
    @PostResource(name = "添加", path = "/figureInfo/add")
    public ResponseData add(@RequestBody @Validated(FigureInfoRequest.add.class) FigureInfoRequest figureInfoRequest) {
        figureInfoService.add(figureInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除
     *
     * @author zhangyaowen
     * @date 2021/10/25 16:46
     */
    @PostResource(name = "删除", path = "/figureInfo/delete")
    public ResponseData delete(@RequestBody @Validated(FigureInfoRequest.delete.class) FigureInfoRequest figureInfoRequest) {
        figureInfoService.del(figureInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     *
     * @author zhangyaowen
     * @date 2021/10/25 16:46
     */
    @PostResource(name = "编辑", path = "/figureInfo/edit")
    public ResponseData edit(@RequestBody @Validated(FigureInfoRequest.edit.class) FigureInfoRequest figureInfoRequest) {
        figureInfoService.edit(figureInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情
     *
     * @author zhangyaowen
     * @date 2021/10/25 16:46
     */
    @GetResource(name = "查看详情", path = "/figureInfo/detail")
    public ResponseData detail(@Validated(FigureInfoRequest.detail.class) FigureInfoRequest figureInfoRequest) {
        return new SuccessResponseData(figureInfoService.detail(figureInfoRequest));
    }

    /**
     * 获取列表
     *
     * @author zhangyaowen
     * @date 2021/10/25 16:46
     */
    @GetResource(name = "获取列表", path = "/figureInfo/list")
    public ResponseData list(FigureInfoRequest figureInfoRequest) {
        return new SuccessResponseData(figureInfoService.findList(figureInfoRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author zhangyaowen
     * @date 2021/10/25 16:46
     */
    @GetResource(name = "分页查询", path = "/figureInfo/page")
    public ResponseData page(String year,String value) {
        return new SuccessResponseData(figureInfoService.findPage(year,value));
    }

    @GetResource(name = "详细信息", path = "/figureInfo/toReview")
    public ResponseData toReview(String id) {
        return new SuccessResponseData(figureInfoService.toReview(id));
    }
}